﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using MetaSharp.Transformation.Properties;
using System.Threading.Tasks;

namespace MetaSharp.Transformation.Tests.Patterns
{
	public class NotTests
	{
		[Fact]
		public async Task NotDefaultFailsOnEmptyInput()
		{
            var p = Pattern.Not(Pattern.Default());
            var m = await Pattern.Match(p, "");
            Assert.False(m.Matched);
		}

		[Fact]
		public async Task NotAnySucceedsOnEmptyInput()
		{
            var p = Pattern.Not(Pattern.Any());
            var m = await Pattern.Match(p, "");
			Assert.True(m.Matched);
		}

		[Fact]
		public async Task NotFailsOnSuccess()
		{
            var p = Pattern.Not(Pattern.Any());
            var m = await Pattern.Match(p, "a");
            Assert.False(m.Matched);
		}

        [Fact]
		public async Task NotDoesNotConsumeInput()
		{
            var p = Pattern.Not(Pattern.Any());
            var m = await Pattern.Match(p, "a");
            Assert.Equal('a', m.End.Stream.Next().Current);
		}

        [Fact]
        public async Task NotNotSucceeds()
        {
            var p = Pattern.Not(Pattern.Not(Pattern.Any()));
            var m = await Pattern.Match(p, "a");
            Assert.True(m.Matched);
        }

        [Fact]
		public async Task NotNotDoesNotConsumeInput()
		{
            var p = Pattern.Not(Pattern.Not(Pattern.Any()));
            var m = await Pattern.Match(p, "a");
            Assert.Equal('a', m.End.Stream.Next().Current);
		}
	}
}
